package org.particles.domain.world;

import java.util.ArrayList;
import java.util.List;

/**
 * combines functions of added resolver in the adding order.
 */
public class CompositeOutOfBoundResolver implements OutOfWorldBoundResolver {
	private List<OutOfWorldBoundResolver> resolvers = new ArrayList<OutOfWorldBoundResolver>(5);

	public CompositeOutOfBoundResolver() {
		
	}
	
	public CompositeOutOfBoundResolver(final List<OutOfWorldBoundResolver> resolvers) {
		this.resolvers = resolvers;
	}
	
	public void addResolver(final OutOfWorldBoundResolver resolver) {
		resolvers.add(resolver);
	}
	
	@Override
	public void resolve(World world, int particleIndex) {
		for(OutOfWorldBoundResolver resolver : resolvers) {
			resolver.resolve(world, particleIndex);
		}
	}

}
